<?php include '../common/session.php' ?>
<?php include '../common/header.php' ?>
<body>
<?php include "menus.php" ?>
<div id="main">
	<h2>文章管理<?php if( $_SESSION['userType'] != 'less' ){  ?><a href="artEdit.php?active=add&id=">+ 添加文章</a><?php } ?></h2>
	<div class="list">
		<table>
			<thead>
				<tr>
					<th width="5%">序号</th><th>标题</th><th>类型</th><th>时间</th><th width="10%">操作</th>
				</tr>
			</thead>
			<tbody></tbody>
		</table>
	</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
	Dir.ajax('new.php',{},function(res){
		var TDs = '';
		for(var i = 0; i < res.length; i++){
			TDs += '<tr lid="'+res[i].id+'"><td>'+(i+1)+'</td><td>'+res[i].title+'</td><td>'+res[i].typeName+'</td><td>'+res[i].time+'</td><td><a class="edit" href="artEdit.php?active=edit&id='+res[i].id+'">编辑</a>　<a class="delete" href="javascript:void(0);">删除</a></td></tr>';
		}
		$('#main tbody').html(TDs);
		if( $('a.exit').attr('ut') == 'less' ){
			$('a.edit,a.delete').css({'color':'#ccc'});
			$('a.edit').attr('href','javascript:void(0);')
		}else{
			$('a.delete').on('click',function(){
				var here = this;
				Dir.popOpen({
					tit : '信息框',
					content : '<div style="padding:10px 0;">是否确定删除?</div>',
					sureCallback : function(){
						Dir.ajax('newDelete.php',{id:$(here).parents('tr').attr('lid')},function(res){
							if( res.status ){
								$(here).parents('tr').remove();
							}
						});
						Dir.popClose();
					}
				});
			});
		}
	});
});
</script>
</body>
</html>